{% extends 'base.html' %}

{% block main %}
    {% if err_msg %}
        <p>
        {{ err_msg }}
        </p>
    {% endif %}
    {% for a in art_list %}
        <article class="post post-idx post-1">
            <header class="entry-header">
                <h1 class="entry-title">
                    <a href="{% url 'blog:detail' pk=a.id %}">{{ a.title }}</a>
                </h1>

            </header>
            <div class="entry-content clearfix">
                <p>{{ a.excerpt }}…&nbsp;&nbsp;&nbsp;&nbsp;<a href="{% url 'blog:detail' pk=a.id %}">阅读全文</a></p>
            </div>
            <div class="entry-meta entry-meta-right">
                <span class="post-category"><a href="{% url 'blog:category' a.category.pk %}">{{ a.category }}</a></span>
                <span class="post-date">
                    <a href="#">
                        <time class="entry-date"
                                      datetime="{{ a.create_time }}">{{ a.create_time |date:'Y-m-d H:i:s' }}</time>
                    </a>
                </span>
                <span class="post-author">
                    <a href="#">{{ a.author }}</a>
                </span>
                <span class="comments-link">
                    <a href="{{ a.get_absolute_url }}#comment-area">{{ a.comment_set.count }} 评论</a>
                </span>
                <span class="views-count"><a href="{{ a.get_absolute_url }}">{{ a.view_count }} 阅读</a></span>
            </div>
        </article>
        {% empty %}
        暂无文章
    {% endfor %}

    <!-- 分页 -->
    {% if is_paginated %}
        <hr style="margin-top: 60px">
        <div style="text-align: center;">
            <ul class="pagination pagination-sm">
                {% if first %}
                    <li><a href="?page=1">1</a></li>
                {% endif %}
                {% if left %}
                    {% if left_has_more %}
                        <li><span>...</span></li>
                    {% endif %}
                    {% for i in left %}
                        <li><a href="?page={{ i }}">{{ i }}</a></li>
                    {% endfor %}
                {% endif %}
                <li class="current"><a href="?page={{ page_obj.number }}">{{ page_obj.number }}</a></li>
                {% if right %}
                    {% for i in right %}
                        <li><a href="?page={{ i }}">{{ i }}</a></li>
                    {% endfor %}
                    {% if right_has_more %}
                        <li><span>...</span></li>
                    {% endif %}
                {% endif %}
                {% if last %}
                    <li><a href="?page={{ paginator.num_pages }}">{{ paginator.num_pages }}</a></li>
                {% endif %}
            </ul>
        </div>
    {% endif %}
{% endblock main %}
